package cn.sm1234;

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class GeneratorSqlmap {
    public static void main(String[] args) throws Exception {
        // 在resources目录下定义配置文件
        String genCig = "/mybatis-gen/generatorConfig.xml";

        System.out.println("开始生成逆向工程.");
        List<String> warnings = new ArrayList<String>();
        boolean overwrite = true;
        File configFile = new File(GeneratorSqlmap.class.getResource(genCig).getFile());
        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(configFile);
        DefaultShellCallback callback = new DefaultShellCallback(overwrite);
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
        myBatisGenerator.generate(null);
        System.out.println("逆向工程生成完毕!");
    }
}
